package com.bootdo.common.service.impl;

import com.bootdo.common.dao.LogDao;
import com.bootdo.common.domain.LogDO;
import com.bootdo.common.domain.PageDO;
import com.bootdo.common.service.CrudService;
import com.bootdo.common.service.LogService;
import com.bootdo.common.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class LogServiceImpl extends CrudService<LogDao, LogDO> implements LogService {
	@Autowired
	LogDao logMapper;

	@Transactional(readOnly = false)
	public void save(LogDO logDO) {
		super.save(logDO);
	}

	@Override
	public PageDO<LogDO> queryList(Query query) {
		int total = logMapper.count(query);
		List<LogDO> logs = logMapper.list(query);
		PageDO<LogDO> page = new PageDO<>();
		page.setTotal(total);
		page.setRows(logs);
		return page;
	}

	@Override
	public int remove(String id) {
		int count = logMapper.remove(id);
		return count;
	}

	@Override
	public int batchRemove(String[] ids){
		return logMapper.batchRemove(ids);
	}
}
